package com.shujia.wyh.day26;

public class SetThread implements Runnable {
    private Student student;
    private int i = 0;
//    private Object obj = new Object();

    SetThread(Student student) {
        this.student = student;
    }

    @Override
    public void run() {
        while (true){
            synchronized (student){
                if(i%2==0){
                    student.name = "李毅";
                    student.age = 18;
                }else {
                    student.name = "小虎";
                    student.age = 16;
                }

                i++;
            }

        }


    }
}
